/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package biermanager.componentes;

import biermanager.nucleo.ConstantesDeJogo;
import java.awt.Font;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.BorderFactory;
import org.jdesktop.swingx.JXLabel;

/**
 *
 * @author Tiago Silva Loureiro
 */
public class Eventos {

    public Eventos() {
    }

    public static void mouseEntraBotaoMenuPrincipal(java.awt.event.MouseEvent evt) {
        final JXLabel jxl = (JXLabel) evt.getSource();

           final Timer tempo = new Timer();            //Temporizador
    TimerTask tarefa = new TimerTask() {     //Objeto tarefa a ser realizada
        private int alpha = 0;
        public void run() {                 //Metodo run que implementa a tarefa
            if ((alpha + 1) <= 5) {
                alpha = alpha + 1;
            } else {
                tempo.cancel();
            }
            jxl.setBorder(BorderFactory.createEmptyBorder( alpha, 3, 3, 10));
        }
    };
            tempo.schedule(tarefa, 50, 5);
        jxl.setBorder(BorderFactory.createEmptyBorder(5, 3, 3, 10));
        Font font = new Font(jxl.getFont().getName(), jxl.getFont().getStyle(), ConstantesDeJogo.tamanhoFonteMenuGrande);
        jxl.setFont(font);
        jxl.setForeground(Cores.amarelo);
    }

    public static void mouseSaiBotaoMenuPrincipal(java.awt.event.MouseEvent evt) {
        JXLabel jxl = (JXLabel) evt.getSource();
        jxl.setBorder(null);
        Font font = new Font(jxl.getFont().getName(), jxl.getFont().getStyle(), ConstantesDeJogo.tamanhoFonteMenu);
        jxl.setFont(font);
        jxl.setForeground(Cores.branco);
    }

    public static void mouseEntraBotao(java.awt.event.MouseEvent evt) {
        PintorDeBackground pintor = new PintorDeBackground();
        JXLabel jxl = (JXLabel) evt.getSource();
        jxl.setBackgroundPainter(pintor.pintarBotaoComFocoCapsulaPreto());
        jxl.setForeground(PintorDeForeground.corSobreBotao());
    }

    public static void mouseSaiBotao(java.awt.event.MouseEvent evt) {
        PintorDeBackground pintor = new PintorDeBackground();
        JXLabel jxl = (JXLabel) evt.getSource();
        jxl.setBackgroundPainter(pintor.pintarBotaoSemFocoCapsulaPreto());
        jxl.setForeground(PintorDeForeground.corBotao());
    }

    public static void mouseEntraFechar(java.awt.event.MouseEvent evt) {
        JXLabel jxl = (JXLabel) evt.getSource();
        jxl.setForeground(PintorDeForeground.corSobreFechar());
        jxl.setBorder(BorderFactory.createEmptyBorder(3, 3, 3, 3));
    }

    public static void mouseSaiFechar(java.awt.event.MouseEvent evt) {
        JXLabel jxl = (JXLabel) evt.getSource();
        jxl.setForeground(PintorDeForeground.corFechar());
        jxl.setBorder(null);
    }
}
